//
//  XZWeatherFutureView.m
//  生活小助手
//
//  Created by MAC－ME on 14-8-8.
//  Copyright (c) 2014年 lxz. All rights reserved.
//

#define ItemW  kScreenWidth / 4
#define ItemH kScreenHeight * .3f / 4


#import "XZWeatherFutureView.h"
#import "XZWeather.h"
#import "XZWeatherIcon.h"

@interface XZWeatherFutureView ()
@property (weak,nonatomic) UILabel  *dateLabel;
@property (weak,nonatomic) UIImageView *weatherImage;
@property (weak,nonatomic) UILabel *tempLabel;
@property (weak,nonatomic) UILabel *weatherLabel;
@end
@implementation XZWeatherFutureView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UILabel *dateLabel = [[UILabel alloc]init];
        dateLabel.font = [UIFont systemFontOfSize:13];
        dateLabel.textColor = [UIColor whiteColor];
        dateLabel.textAlignment = NSTextAlignmentCenter;
        dateLabel.backgroundColor = [UIColor clearColor];
        dateLabel.text = @"星期天";
        [self addSubview:dateLabel];
        self.dateLabel = dateLabel;
        
        UIImageView *weatherImage = [[UIImageView alloc]init];
        weatherImage.backgroundColor = [UIColor clearColor];
        weatherImage.image = [UIImage imageNamed:@"smallrain"];
        weatherImage.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:weatherImage];
        self.weatherImage = weatherImage;
        
        UILabel *weatherLabel = [[UILabel alloc]init];
        weatherLabel.backgroundColor = [UIColor clearColor];
        weatherLabel.textColor = [UIColor whiteColor];
        weatherLabel.font = [UIFont systemFontOfSize:13];
        weatherLabel.textAlignment = NSTextAlignmentCenter;
        weatherLabel.textAlignment = NSTextAlignmentCenter;
        weatherLabel.text = @"晴转霾";
        [self addSubview:weatherLabel];
        self.weatherLabel = weatherLabel;

        UILabel *tempLabel = [[UILabel alloc]init];
        tempLabel.backgroundColor = [UIColor clearColor];
        tempLabel.textColor = [UIColor whiteColor];
        tempLabel.font = [UIFont systemFontOfSize:13];
        tempLabel.textAlignment = NSTextAlignmentCenter;
        tempLabel.text = @"21°~29°";
        [self addSubview:tempLabel];
        self.tempLabel = tempLabel;
        
        
    }
    return self;
}
- (void)setWeather:(XZWeather *)weather
{
    _weather = weather;
    
    self.dateLabel.text = weather.week;
    self.tempLabel.text = weather.temperature;
    self.weatherLabel.text = weather.weather;
    self.weatherImage.image = [XZWeatherIcon weatherIconWithWeatherId:weather.weather_id];
    
    [self setNeedsLayout];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
   
    self.dateLabel.frame = CGRectMake(0, 0, ItemW, ItemH);
    self.weatherImage.frame = CGRectMake((self.width - ItemH) / 2, ItemH, ItemH, ItemH);
    self.weatherLabel.frame = CGRectMake(0, ItemH * 2, ItemW, ItemH);
    self.tempLabel.frame = CGRectMake(0, ItemH * 3, ItemW, ItemH);
    
}
@end
